package com.zw.pdm.module.report.service;

import com.zw.pdm.entity.rep.Change;
import com.zw.pdm.entity.rep.Plan;
import com.zw.pdm.entity.rep.Result;
import com.zw.pdm.entity.rep.Sheet;
import com.zw.pdm.module.report.mapper.ChangeMapper;
import com.zw.pdm.module.report.mapper.PlanMapper;
import com.zw.pdm.module.report.mapper.SheetMapper;
import com.zw.pdm.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Description:
 *
 * @Author: China.sgl
 * @Date: 2019/12/6 08:42
 */
@Service
@SuppressWarnings("all")
public class ReportQueryService {

    @Autowired
    private PlanMapper planMapper;
    @Autowired
    private SheetMapper sheetMapper;
    @Autowired
    private ChangeMapper changeMapper;

    /** 列表查询 */
    public List<Sheet> findWithReportQuery(Sheet sheet) {
        if (sheet.getDept() == null) {
            sheet.setDept(ShiroUtils.getUser().getDept());
        } else if(sheet.getDept() == -1) {
            sheet.setDept(null);
        }
        return sheetMapper.findWithReportQuery(sheet);
    }

    /** 查询计划单明细 */
    public List<Plan> findPlanDetailList(Plan plan) {
        return planMapper.findPlanDetailList(plan);
    }

    /** 查询变更计划单明细 */
    public List<Change> findChangeDetailList(Change change) {
        return changeMapper.findChangeDetailList(change);
    }

    /**
     * 外购件输出表
     *
     * @param result
     * @return
     */
    public List<Result> findRepResultByQuery(Result result) {
        return planMapper.findRepResultByQuery(result);
    }

}
